package com.ssk.sh.model;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ssk.sh.core.enums.ChatTypeEnum;
import com.ssk.sh.core.enums.handler.BigIntArrayTypeHandler;
import io.swagger.v3.oas.annotations.media.Schema;
import java.io.Serializable;
import java.time.OffsetDateTime;
import java.util.List;
import lombok.Getter;
import lombok.Setter;

/**
 * <p>
 *
 * </p>
 *
 * @author ssk
 * @since 2025-06-12
 */
@Getter
@Setter
@TableName(value = "chats", autoResultMap = true)
@Schema(name = "Chats", description = "")
@KeySequence(value = "chats_id_seq", dbType = DbType.POSTGRE_SQL)  // 绑定 PostgreSQL 序列 postgreKeyGenerator
public class Chats implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.INPUT)
    private Long id;

    @TableField("ws_id")
    private Long wsId;

    @TableField("name")
    private String name;

    @TableField(value = "type")
    private ChatTypeEnum type;

    @TableField(typeHandler = BigIntArrayTypeHandler.class, value = "members")
//    @TableField(typeHandler = ArrayTypeHandler.class, value = "members",jdbcType = JdbcType.ARRAY,javaType=true)
    private List<Long> members;

    @TableField(value = "created_at", fill = FieldFill.INSERT)
    private OffsetDateTime createdAt;

    public static final String ID = "id";

    public static final String WS_ID = "ws_id";

    public static final String NAME = "name";

    public static final String TYPE = "type";

    public static final String MEMBERS = "members";

    public static final String CREATED_AT = "created_at";
}
